package top.lshaci.learning.alibaba.cloud.seata.order.api;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lshaci.learning.alibaba.cloud.seata.order.entity.Order;
import top.lshaci.learning.alibaba.cloud.seata.order.service.OrderService;

/**
 * OrderController
 *
 * @author lshaci
 * @since 1.0.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/order")
public class OrderController {

    private final OrderService orderService;

    /**
     * 从用户账户中借出
     */
    @GetMapping("/debit/{userId}/{commodityCode}/{orderCount}")
    public Order create(@PathVariable String userId, @PathVariable String commodityCode, @PathVariable int orderCount) {
        Order order = orderService.create(userId, commodityCode, orderCount);
        return order;
    }
}
